Skip to content

refactor: derive agent counts from the PDL, one entity one agent (#37) - #44

Open
Hackatro wants to merge 1 commit into
mainfrom
37-pdl-literal-agent-counts-n1-and-wholesaler-passthrough
Open

Hackatro wants to merge 1 commit into
mainfrom
37-pdl-literal-agent-counts-n1-and-wholesaler-passthrough

Conversation

@Hackatro

Copy link
Copy Markdown
Contributor

#37 — PDL-literal agent counts (n=1) and consumer split

One PDL entity is now one agent. The n_* count columns are gone from scenario.py and both scenario CSVs, count_attr is gone from topology.py and model.py, and the pooled eu_farmers list is split into poultry_farms, pig_farms and dairy_farms: three roster entries named after their entity ids, exactly like producers and wholesalers. Wholesaler economics are untouched.

Scenario 0, final period

Before After
Produced 2300 t 300 t
Delivered to processors 800 t 300 t
soy_price 523.41 673.20
feed_price 1263.00 2618.81
Transport utilisation 0.50 0.14
Producer unit prices (BRA/ARG/US) 396 / 462 / 528 unchanged

Findings

  • Bugfix: _step_consumer divided the traders' feed by the agents in its own list, which after the split would have delivered three times the feed produced.
  • Prices rise because fixed costs are per-agent and throughput fell tenfold.
  • No capacity binds any more. Reasoning, not measurement: Argentina and the US alone offered 1300 t into a Rotterdam lane capped at 500, so a Brazilian drought left delivered volume there unchanged and only the Hamburg branch responded. At n=1 there is no surplus, so a supply shock now passes through the chain proportionally.

Follow-ups being filed

  1. Chain constants — capacities, SEA_CAPACITY, base_yield and the fixed_costs_* are calibrated against agent counts that no longer exist.
  2. Consumer modelling: consumers ignore PDL impacts aimed at them (livestock_pressure declares supply −9% / price +20% on poultry_farms), and the feed share assumes all consumers share one upstream.

- Agent counts came from n_* scenario columns the PDL does not contain. setup_agents(1) now populates one agent per roster entry.
- The pooled eu_farmers list splits into poultry_farms, pig_farms and dairy_farms, named after their entity ids like producers and wholesalers
- _step_consumer divided trader feed by the agents in its own list, derived from the foster.
- shock_ramp_steps is deleted alongside the eight n_* columns
- wholesaler economics untouched

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The critical one-entity/one-agent roster binding issue remains unresolved; the README also needs a schema-name correction.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Refactors agent counts to derive one agent per PDL entity and splits EU consumers into separate rosters.

Changes:

  • Removes invented count fields and CSV columns.
  • Updates topology, consumer feed allocation, tests, fixtures, and documentation.
  • Review notes identify a roster-binding issue in model.py and an outdated README output name.
File Summary
tests/​test_transport_routing.py Updates transport routing coverage.
tests/​test_topology_snapshot.py Removes count metadata assertions.
tests/​test_topology_export_contract.py Validates split consumer nodes and edges.
tests/​fixtures/​topology_snapshot_23.py Refreshes roster and adjacency fixtures.
src/​provider_simenv/​topology.py Removes count metadata and splits consumer rosters.
src/​provider_simenv/​scenario.py Removes population-count parameters.
src/​provider_simenv/​model.py Initializes roster agents; fixed-name entities may still be grouped incorrectly.
src/​provider_simenv/​data/​input/​SimulatorScenarios.csv Removes count columns.
src/​provider_simenv/​data/​input/​SimulatorScenarios_template.csv Updates the scenario schema.
src/​provider_simenv/​agents/​farmer.py Shares feed across active consumers.
README.md Documents PDL-derived counts; one output name remains outdated.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

arc = entry.archetype
agent_list = getattr(self, arc.name)
agent_list.setup_agents(getattr(self.scenario, arc.count_attr))
agent_list.setup_agents(1)
Comment thread README.md
Comment on lines +150 to +151
Each row is one run. Columns are engine parameters (routing, size sigmas, storage, length).
Agent counts are not CSV columns — the roster derives one agent per PDL entity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDL-literal agent counts (n=1) and wholesaler passthrough

2 participants